```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分布式系统ID生成策略解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f8f9fa;
            color: #333;
            line-height: 1.6;
        }
        .hero {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
            color: white;
        }
        .card {
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            border-radius: 12px;
            overflow: hidden;
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .pros-cons {
            position: relative;
        }
        .pros-cons::before {
            content: "";
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 4px;
            background: linear-gradient(to bottom, #4facfe 0%, #00f2fe 100%);
            border-radius: 2px;
        }
        .code-block {
            background-color: #282c34;
            color: #abb2bf;
            border-radius: 8px;
            position: relative;
        }
        .copy-btn {
            position: absolute;
            right: 10px;
            top: 10px;
            background-color: rgba(255, 255, 255, 0.1);
            border: none;
            color: white;
            padding: 2px 8px;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.2s;
        }
        .copy-btn:hover {
            background-color: rgba(255, 255, 255, 0.2);
        }
        .footer {
            background-color: #1a1a1a;
            color: #e0e0e0;
        }
        .footer a {
            transition: color 0.2s;
        }
        .footer a:hover {
            color: #6e8efb;
        }
        .highlight {
            background: linear-gradient(120deg, #f6d365 0%, #fda085 100%);
            background-repeat: no-repeat;
            background-size: 100% 40%;
            background-position: 0 90%;
        }
    </style>
</head>
<body class="min-h-screen flex flex-col">
    <!-- Hero Section -->
    <section class="hero py-20 px-4 sm:px-6 lg:px-8">
        <div class="max-w-5xl mx-auto text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6 font-serif">分布式系统<span class="highlight">ID生成</span>策略解析</h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90">探索高并发环境下实现全局唯一且自增ID的多种解决方案</p>
            <div class="flex justify-center space-x-4">
                <a href="#database" class="px-6 py-3 bg-white text-purple-600 rounded-full font-medium hover:bg-opacity-90 transition-all">数据库方案</a>
                <a href="#snowflake" class="px-6 py-3 bg-white bg-opacity-20 backdrop-blur-sm rounded-full font-medium hover:bg-opacity-30 transition-all">雪花算法</a>
                <a href="#uuid" class="px-6 py-3 bg-white bg-opacity-20 backdrop-blur-sm rounded-full font-medium hover:bg-opacity-30 transition-all">UUID方案</a>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="flex-grow py-12 px-4 sm:px-6 lg:px-8 max-w-6xl mx-auto">
        <!-- Introduction -->
        <section class="mb-16">
            <div class="prose max-w-none">
                <p class="text-lg text-gray-700 mb-6">在分布式系统中，实现一个<span class="font-bold text-purple-600">全局唯一且自增的ID生成策略</span>是一项常见但具有挑战性的任务。这种需求出现在需要为记录、事务或其他唯一标识符生成唯一ID的场景中。</p>
                <p class="text-lg text-gray-700">本文将深入探讨四种主流实现方案，分析它们的原理、优缺点以及适用场景，帮助你为项目选择最合适的ID生成策略。</p>
            </div>
        </section>

        <!-- Visualization -->
        <section class="mb-16 bg-white rounded-xl shadow-md p-6">
            <h2 class="text-2xl font-bold mb-6 font-serif text-center">ID生成方案对比概览</h2>
            <div class="mermaid">
                graph TD
                    A[ID生成策略] --> B[数据库自增ID]
                    A --> C[雪花算法]
                    A --> D[UUID]
                    A --> E[数据库序列]
                    
                    B -->|简单易用| F[适合小型系统]
                    B -->|性能瓶颈| G[分布式环境下有限制]
                    
                    C -->|分布式友好| H[高性能]
                    C -->|避免中心化| I[需要管理机器ID]
                    
                    D -->|全局唯一| J[无需协调]
                    D -->|无序| K[不适合排序]
                    
                    E -->|高并发支持| L[数据库依赖]
                    E -->|可扩展性| M[可能成为瓶颈]
            </div>
        </section>

        <!-- Database Auto Increment -->
        <section id="database" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-blue-100 p-3 rounded-lg mr-4">
                    <i class="fas fa-database text-blue-600 text-2xl"></i>
                </div>
                <h2 class="text-3xl font-bold font-serif">1. 数据库自增 ID</h2>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="pros-cons p-6 bg-white rounded-lg shadow-sm">
                    <h3 class="text-xl font-semibold mb-4">核心原理</h3>
                    <p class="mb-6">利用数据库的内置自增字段(如MySQL的AUTO_INCREMENT)来生成唯一且自增的ID。每插入一行记录时，数据库自动生成一个递增的ID值。</p>
                    
                    <h3 class="text-xl font-semibold mb-4">优点</h3>
                    <ul class="space-y-2 mb-6">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>实现简单直接，易于理解和使用</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>天然保证ID的唯一性和递增性</span>
                        </li>
                    </ul>
                    
                    <h3 class="text-xl font-semibold mb-4">缺点</h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-times-circle text-red-500 mr-2 mt-1"></i>
                            <span>在分布式环境中，数据库可能成为单点故障</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times-circle text-red-500 mr-2 mt-1"></i>
                            <span>高并发场景下性能受限，因为需要数据库锁或事务控制</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times-circle text-red-500 mr-2 mt-1"></i>
                            <span>数据库扩展或分库分表时ID生成变得复杂</span>
                        </li>
                    </ul>
                </div>
                
                <div>
                    <div class="bg-gray-50 p-6 rounded-lg h-full">
                        <h3 class="text-xl font-semibold mb-4">适用场景</h3>
                        <p class="mb-6">适合单机或小型系统，对性能要求不高且不需要分布式部署的场景。</p>
                        
                        <h3 class="text-xl font-semibold mb-4">实现示例</h3>
                        <pre class="code-block p-4 text-sm rounded-lg overflow-x-auto">
<button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
<code>CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(50) NOT NULL,
    email VARCHAR(100) NOT NULL
);

-- 插入数据时，id会自动递增
INSERT INTO users (username, email) VALUES ('user1', 'user1@example.com');
INSERT INTO users (username, email) VALUES ('user2', 'user2@example.com');</code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- Snowflake -->
        <section id="snowflake" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-purple-100 p-3 rounded-lg mr-4">
                    <i class="fas fa-snowflake text-purple-600 text-2xl"></i>
                </div>
                <h2 class="text-3xl font-bold font-serif">2. 雪花算法 (Snowflake)</h2>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="pros-cons p-6 bg-white rounded-lg shadow-sm">
                    <h3 class="text-xl font-semibold mb-4">核心原理</h3>
                    <p class="mb-4">Twitter开发的分布式ID生成算法，ID由以下部分组成：</p>
                    <ul class="space-y-2 mb-6">
                        <li class="flex items-start">
                            <span class="bg-gray-100 px-2 py-1 rounded mr-2 font-mono">时间戳</span>
                            <span>当前时间的毫秒数</span>
                        </li>
                        <li class="flex items-start">
                            <span class="bg-gray-100 px-2 py-1 rounded mr-2 font-mono">数据中心ID</span>
                            <span>标识生成ID的数据中心</span>
                        </li>
                        <li class="flex items-start">
                            <span class="bg-gray-100 px-2 py-1 rounded mr-2 font-mono">机器ID</span>
                            <span>标识生成ID的机器</span>
                        </li>
                        <li class="flex items-start">
                            <span class="bg-gray-100 px-2 py-1 rounded mr-2 font-mono">序列号</span>
                            <span>同一时间戳下的自增序列</span>
                        </li>
                    </ul>
                    
                    <h3 class="text-xl font-semibold mb-4">优点</h3>
                    <ul class="space-y-2 mb-6">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>分布式环境下高性能生成ID</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>不依赖中心化数据库，避免单点故障</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>生成的ID大致有序，便于数据库索引</span>
                        </li>
                    </ul>
                    
                    <h3 class="text-xl font-semibold mb-4">缺点</h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-times-circle text-red-500 mr-2 mt-1"></i>
                            <span>需要解决时钟回拨问题</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times-circle text-red-500 mr-2 mt-1"></i>
                            <span>需要管理和分配机器ID与数据中心ID</span>
                        </li>
                    </ul>
                </div>
                
                <div>
                    <div class="bg-gray-50 p-6 rounded-lg h-full">
                        <h3 class="text-xl font-semibold mb-4">适用场景</h3>
                        <p class="mb-6">适合大规模分布式系统，需要高性能、高可用的ID生成服务。</p>
                        
                        <h3 class="text-xl font-semibold mb-4">Java实现示例</h3>
                        <pre class="code-block p-4 text-sm rounded-lg overflow-x-auto">
<button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
<code>public class SnowflakeIdGenerator {
    private static final long START_TIMESTAMP = 1609459200000L;
    private static final long DATA_CENTER_ID_BITS = 5L;
    private static final long MACHINE_ID_BITS = 5L;
    private static final long SEQUENCE_BITS = 12L;
    
    private static final long MAX_DATA_CENTER_ID = ~(-1L << DATA_CENTER_ID_BITS);
    private static final long MAX_MACHINE_ID = ~(-1L << MACHINE_ID_BITS);
    private static final long SEQUENCE_MASK = ~(-1L << SEQUENCE_BITS);
    
    private long dataCenterId;
    private long machineId;
    private long sequence = 0L;
    private long lastTimestamp = -1L;

    public SnowflakeIdGenerator(long dataCenterId, long machineId) {
        if (dataCenterId > MAX_DATA_CENTER_ID || dataCenterId < 0) {
            throw new IllegalArgumentException("Data center ID is out of range");
        }
        if (machineId > MAX_MACHINE_ID || machineId < 0) {
            throw new IllegalArgumentException("Machine ID is out of range");
        }
        this.dataCenterId = dataCenterId;
        this.machineId = machineId;
    }

    public synchronized long generateId() {
        long timestamp = timeGen();
        if (timestamp < lastTimestamp) {
            throw new RuntimeException("Clock moved backwards");
        }
        if (timestamp == lastTimestamp) {
            sequence = (sequence + 1) & SEQUENCE_MASK;
            if (sequence == 0) {
                timestamp = tilNextMillis(lastTimestamp);
            }
        } else {
            sequence = 0;
        }
        lastTimestamp = timestamp;
        return ((timestamp - START_TIMESTAMP) << (DATA_CENTER_ID_BITS + MACHINE_ID_BITS + SEQUENCE_BITS))
                | (dataCenterId << (MACHINE_ID_BITS + SEQUENCE_BITS))
                | (machineId << SEQUENCE_BITS)
                | sequence;
    }

    private long tilNextMillis(long lastTimestamp) {
        long timestamp = timeGen();
        while (timestamp <= lastTimestamp) {
            timestamp = timeGen();
        }
        return timestamp;
    }

    private long timeGen() {
        return System.currentTimeMillis();
    }
}</code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- UUID -->
        <section id="uuid" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-indigo-100 p-3 rounded-lg mr-4">
                    <i class="fas fa-fingerprint text-indigo-600 text-2xl"></i>
                </div>
                <h2 class="text-3xl font-bold font-serif">3. UUID (通用唯一标识符)</h2>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="pros-cons p-6 bg-white rounded-lg shadow-sm">
                    <h3 class="text-xl font-semibold mb-4">核心原理</h3>
                    <p class="mb-6">UUID是一种标准化的128位标识符，通常表示为32个十六进制数字，由连字符分隔为五组，形如：8-4-4-4-12的36个字符。</p>
                    
                    <h3 class="text-xl font-semibold mb-4">优点</h3>
                    <ul class="space-y-2 mb-6">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>实现简单，语言标准库通常已内置支持</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>分布式环境下无需协调即可保证唯一性</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>
                            <span>不依赖中心化服务或数据库</span>
                        </li>
                    </ul>
                    
                    <h3 class="text-xl font-semibold mb-4">缺点</h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-times-circle text-red-500 mr-2 mt-1"></i>
                            <span>ID较长(36字符)，存储和索引效率较低</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times-circle text-red-500 mr-2 mt-1"></i>
                            <span>完全无序，无法反映生成顺序</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times-circle text-red-500 mr-2 mt-1"></i>
                            <span>可读性差，不适合作为用户可见的标识</span>
                        </li>
                    </ul>
                </div>
                
                <div>
                    <div class="bg-gray-50 p-6 rounded-lg h-full">
                        <h3 class="text-xl font-semibold mb-4">适用场景</h3>
                        <p class="mb-6">适合不需要ID有序且能接受较长ID的场景，如临时令牌、非关键数据标识等。</p>
                        
                        <h3 class="text-xl font-semibold mb-4">Java实现示例</h3>
                        <pre class="code-block p-4 text-sm rounded-lg overflow-x-auto">
<button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
<code>import java.util.UUID;

public class UUIDGenerator {
    public static String generateId() {
        return UUID.randomUUID().toString();
    }

    public static void main(String[] args) {
        String id = generateId();
        System.out.println("Generated UUID: " + id);
        // 示例输出: Generated UUID: 550e8400-e29b-41d4-a716-446655440000
    }
}</code></pre>
                        
                        <h3 class="text-xl font-semibold mt-6 mb-4">数据库序列实现</h3>
                        <pre class="code-block p-4 text-sm rounded-lg overflow-x-auto">
<button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i></button>
<code>-- 创建序列
CREATE SEQUENCE my_sequence START WITH 1 INCREMENT BY 1;

-- 使用序列生成 ID
SELECT nextval('my_sequence');</code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary Table -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 font-serif text-center">ID生成方案对比总结</h2>
            <div class="overflow-x-auto bg-white rounded-lg shadow-sm">
                <table class="min-w-full divide-y divide-gray-200">
                    <thead class="bg-gray-50">
                        <tr>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">方案</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">唯一性</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">有序性</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">分布式支持</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">性能</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID长度</th>
                        </tr>
                    </thead>
                    <tbody class="bg-white divide-y divide-gray-200">
                        <tr class="hover:bg-gray-50">
                            <td class="px-6 py-4 whitespace-nowrap font-medium">数据库自增ID</td>
                            <td class="px-6 py-4 whitespace-nowrap text-green-600">高</td>
                            <td class="px-6 py-4 whitespace-nowrap text-green-600">严格递增</td>
                            <td class="px-6 py-4 whitespace-nowrap text-red-600">差</td>
                            <td class="px-6 py-4 whitespace-nowrap text-yellow-600">中</td>
                            <td class="px-6 py-4 whitespace-nowrap">短(如64位整数)</td>
                        </tr>
                        <tr class="hover:bg-gray-50">
                            <td class="px-6 py-4 whitespace-nowrap font-medium">雪花算法</td>
                            <td class="px-6 py-4 whitespace-nowrap text-green-600">高</td>
                            <td class="px-6 py-4 whitespace-nowrap text-green-600">大致有序</td>
                            <td class="px-6 py-4 whitespace-nowrap text-green-600">优</td>
                            <td class="px-6 py-4 whitespace-nowrap text-green-600">高</td>
                            <td class="px-6 py-4 whitespace-nowrap">中(64位整数)</td>
                        </tr>
                        <tr class="hover:bg-gray-50">
                            <td class="px-6 py-4 whitespace-nowrap font-medium">UUID</td>
                            <td class="px-6 py-4 whitespace-nowrap text-green-600">极高</td>
                            <td class="px-6 py-4 whitespace-nowrap text-red-600">无序</td>
                            <td class="px-6 py-4 whitespace-nowrap text-green-600">优</td>
                            <td class="px-6 py-4 whitespace-nowrap text-green-600">高</td>
                            <td class="px-6 py-4 whitespace-nowrap">长(36字符)</td>
                        </tr>
                        <tr class="hover:bg-gray-50">
                            <td class="px-6 py-4 whitespace-nowrap font-medium">数据库序列</td>
                            <td class="px-6 py-4 whitespace-nowrap text-green-600">高</td>
                            <td class="px-6 py-4 whitespace-nowrap text-green-600">严格递增</td>
                            <td class="px-6 py-4 whitespace-nowrap text-yellow-600">中</td>
                            <td class="px-6 py-4 whitespace-nowrap text-yellow-600">中</td>
                            <td class="px-6 py-4 whitespace-nowrap">短(如64位整数)</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </section>

        <!-- Conclusion -->
        <section class="bg-white rounded-xl shadow-md p-8 mb-16">
            <h2 class="text-3xl font-bold mb-6 font-serif text-center">如何选择适合的方案？</h2>
            <div class="prose max-w-none">
                <p class="text-lg text-gray-700 mb-4">选择ID生成策略时，需要根据具体业务需求和技术环境权衡以下因素：</p>
                <ul class="space-y-3 mb-6">
                    <li class="flex items-start">
                        <i class="fas fa-check text-purple-500 mr-2 mt-1"></i>
                        <span><strong>分布式需求</strong>：是否需要支持分布式部署？节点数量多少？</span>
                    </li>
                    <li class="flex items-start">
                        <i class="fas fa-check text-purple-500 mr-2 mt-1"></i>
                        <span><strong>性能要求</strong>：预期的QPS是多少？对延迟的敏感度如何？</span>
                    </li>
                    <li class="flex items-start">
                        <i class="fas fa-check text-purple-500 mr-2 mt-1"></i>
                        <span><strong>ID特性</strong>：是否需要严格有序？ID长度限制？可读性要求？</span>
                    </li>
                    <li class="flex items-start">
                        <i class="fas fa-check text-purple-500 mr-2 mt-1"></i>
                        <span><strong>运维复杂度</strong>：能否接受额外的运维成本（如管理机器ID）？</span>
                    </li>
                </ul>
                <div class="bg-blue-50 p-6 rounded-lg border border-blue-100">
                    <h3 class="text-xl font-semibold mb-3 text-blue-800">推荐建议</h3>
                    <p class="text-blue-700">对于大多数分布式系统，<span class="font-bold">雪花算法</span>是一个平衡性很好的选择。它在保证高性能和分布式特性的同时，生成的ID较为紧凑且大致有序。若系统规模较小或对数据库有强依赖，可以考虑<span class="font-bold">数据库自增ID或序列</span>。当唯一性是唯一要求且不关心顺序时，<span class="font-bold">UUID</span>是最简单的解决方案。</p>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="footer py-8 px-4 sm:px-6 lg:px-8">
        <div class="max-w-6xl mx-auto flex flex-col md:flex-row justify-between items-center">
            <div class="mb-4 md:mb-0">
                <p class="text-lg font-medium">技术小馆</p>
                <p class="text-sm opacity-80">探索技术之美，分享开发智慧</p>
            </div>
            <div>
                <a href="http://www.yuque.com/jtostring" class="flex items-center text-sm hover:text-white transition-colors">
                    <i class="fas fa-globe mr-2"></i> http://www.yuque.com/jtostring
                </a>
            </div>
        </div>
    </footer>

    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true,
                curve: 'basis'
            }
        });

        // Copy code function
        function copyCode(button) {
            const codeBlock = button.parentNode;
            const code = codeBlock.querySelector('code').textContent;
            navigator.clipboard.writeText(code).then(() => {
                const originalIcon = button.innerHTML;
                button.innerHTML = '<i class="fas fa-check"></i>';
                setTimeout(() => {
                    button.innerHTML = originalIcon;
                }, 2000);
            });
        }

        // Smooth scrolling for anchor links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```